import time

import Page
from Base.base import Base

class PageLongin(Base):
    # 点击我
    def page_click_me(self):
        self.base_click_element(Page.aplai_me)

    # 点击已有账号
    def page_exist_user(self):
        self.base_click_element(Page.exits_user)

    # 输入用户名
    def page_input_user(self,username):
        self.base_input_text(Page.input_user,username)

    # 输入密码
    def page_input_pwd(self,pwd):
        self.base_input_text(Page.input_pwd,pwd)

    # 点击登录按钮
    def page_click_login_btn(self):
        self.base_click_element(Page.click_login_btn)

    # 断言
    def page_ass_username(self):
        return self.base_get_element_text(Page.username_text)

    # 点击设置按钮
    def page_click_setting_btn(self):
        self.base_click_element(Page.setting_btn)

    # 滑动拖拽元素
    def page_drag_and_drop_find_ele(self):
        el1 = self.base_find_element(Page.el1)
        el2 = self.base_find_element(Page.el2)
        self.driver.drag_and_drop(el1, el2)

    # 点击退出
    def page_exit_btn(self):
        self.base_click_element(Page.exit_btn)

    # 点击确认退出按钮
    def page_ok_btn(self):
        self.base_click_element(Page.yes_exit_btn)

    # toast断言用户名错误
    def page_username_toast_ass(self):
        return self.base_get_toast(Page.username_no_exist_toast)

    # toast断言密码错误
    def page_pwd_toast_ass(self):
        return self.base_get_toast(Page.pwd_no_exist_toast)

    # 点击地址管理
    def page_click_address(self):
        self.base_click_element(Page.el2)

    # 点击新增地址
    def page_click_add_address(self):
        self.base_click_element(Page.add_address)
    # 输入收件人姓名
    def page_shoujian_name(self,sjname):
        self.base_input_text(Page.shoujian_name,sjname)
    # 输入手机号
    def page_phone_text(self,phone):
        self.base_input_text(Page.phone_text,phone)
    # 选择所在地区
    def page_area_select(self):
        self.base_click_element(Page.area_select_click)
    # 选择城市
    def page_chengshi_select(self):
        self.base_click_element(Page.chengshi_select)
    # 再次点击城市
    def page_chengshi_click(self):
        self.base_click_element(Page.chengshi_click)
    # 选择县
    def page_xian_click(self):
        self.base_click_element(Page.xian_click)
    #详细地址
    def page_xiangxi_address_text(self,xianxi):
        self.base_input_text(Page.xiangxi_address,xianxi)

    # 输入邮编
    def page_youbain_text(self,youbian):
        self.base_input_text(Page.youbian_text,youbian)
    # 设为默认地址
    def page_mo_address(self):
        self.base_click_element(Page.mo_address)
    # 点击保存
    def page_click_save(self):
        self.base_click_element(Page.seve_click)
    # 组装方法
    def page_bainianaolai_login(self,username,pwd):
        self.base_click_element(Page.aplai_me)
        self.base_click_element(Page.exits_user)
        self.base_input_text(Page.input_user,username)
        self.base_input_text(Page.input_pwd, pwd)
        self.base_click_element(Page.click_login_btn)
        self.base_click_element(Page.setting_btn)
        el1 = self.base_find_element(Page.el1)
        el2 = self.base_find_element(Page.el2)
        self.driver.drag_and_drop(el1, el2)
        self.base_click_element(Page.exit_btn)
        self.base_click_element(Page.yes_exit_btn)



    # 新增地址组装
    def page_bainianaolai_address(self,sjname,phone,xianxi,youbian):
        # 点击地址管理
        self.base_click_element(Page.el2)
        # 点击新增地址
        self.base_click_element(Page.add_address)
        # 输入收件人姓名
        self.base_input_text(Page.shoujian_name, sjname)
        # 输入手机号
        self.base_input_text(Page.phone_text, phone)
        # 选择所在地区
        self.base_click_element(Page.area_select_click)
        # 选择城市
        self.base_click_element(Page.chengshi_select)
        # 再次点击城市
        self.base_click_element(Page.chengshi_click)
        # 选择县
        self.base_click_element(Page.xian_click)
        # 详细地址
        self.base_input_text(Page.xiangxi_address, xianxi)
        # 输入邮编
        self.base_input_text(Page.youbian_text, youbian)
        # 设为默认地址
        self.base_click_element(Page.mo_address)
        # 点击保存
        self.base_click_element(Page.seve_click)

    def page_bainianaolai_login1(self,username, pwd):
        self.base_click_element(Page.aplai_me)
        self.base_click_element(Page.exits_user)
        self.base_input_text(Page.input_user, username)
        self.base_input_text(Page.input_pwd, pwd)
        self.base_click_element(Page.click_login_btn)
        time.sleep(2)
        self.base_click_element(Page.setting_btn)

    # 百年断言
    def page_assa_username(self):
        return self.base_get_element_text(Page.bainain_text)







